package com.glorysoft.xztpda.ui.lotinfo

import androidx.databinding.ObservableArrayList
import com.glorysoft.sunnypda.entity.ui.CallObserveBean
import com.glorysoft.xztpda.BR
import com.glorysoft.xztpda.R
import com.glorysoft.xztpda.base.BaseViewModel
import com.glorysoft.xztpda.entity.LotInfoEntity
import com.glorysoft.xztpda.model.LotRepository
import com.google.gson.JsonObject
import me.tatarka.bindingcollectionadapter2.ItemBinding

/**
 * FileName: LotQueryViewModel
 * Author: XJH
 * Date: 2022/7/5 17:47
 * Description:
 * History:
 */
class LotQueryViewModel : BaseViewModel() {

    private val repository: LotRepository = LotRepository()

    var lotInfoItems = ObservableArrayList<LotInfoEntity>()
    var lotInfoBinding =
        ItemBinding.of<LotInfoEntity>(BR.lotInfoItem, R.layout.item_lot_info)

    fun getLotInfo(lot: String) {
        val map = JsonObject()
        map.addProperty("ACTIONTYPE", "LOTINFOBYID")
        map.addProperty("LOTID", lot)
        launchOnlyResult({
            val lotInfo = repository.getLotInfo(map)
            lotInfoItems.clear()
            lotInfoItems.add(lotInfo)
        })

    }
}